package com.spring.origin;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserService {

    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void execute(){
        UserDao dao = new UserDaoImpl();
        dao.add();
    }

    public void exec(){
        UserDao dao = DaoFactory.getDao();
        dao.create();
    }

    @Test
    public void test(){

        userDao.create();
    }


    public static void main(String[] args) {
        // execute();
        // exec();
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
        UserService userService = context.getBean("userService", UserService.class);
        userService.test();
    }
}
